package finalproject.client;

import java.util.List;
import finalproject.shared.Docent;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import finalproject.client.ProjectService;
import finalproject.client.ProjectServiceAsync;

public class DocentClass {
    private ProjectServiceAsync projectService = GWT.create(ProjectService.class);
    DocentGui gui;
    
    
    // List Docenten.
     
    void listDocenten() {
    	projectService.listDocenten(new AsyncCallback<List<Docent>> () {
                    public void onFailure(Throwable caught) {
                        gui.service_eventListDocentenFailed(caught);
                    }
        
                    public void onSuccess(List<Docent> result) {
                        gui.service_eventListRetrievedFromService(result);
                        
                    }
        }
        );
    }
    
    
      //Add Docent.
  
    void addDocent(final Docent docent) {
    	projectService.addDocent(docent, new AsyncCallback<Void> () {
            public void onFailure(Throwable caught) {
                gui.service_eventAddDocentFailed(caught);
            }

            public void onSuccess(Void result) {
                gui.service_eventAddDocentSuccessful();
            }
        }
        );      
    }

    //update docent
    
    void updateDocent(final Docent docent) {
    	projectService.updateDocent(docent, new AsyncCallback<Void> () {
            public void onFailure(Throwable caught) {
                gui.service_eventUpdateDocentFailed(caught);
            }

            public void onSuccess(Void result) {
                gui.service_eventUpdateDocentSuccessful();
            }
        }
        );
    }

// removes docent 
    
    void removeDocent(final Docent docent) {
    	projectService.removeDocent(docent, new AsyncCallback<Void> () {
            public void onFailure(Throwable caught) {
                gui.service_eventRemoveDocentFailed(caught);
            }

            public void onSuccess(Void result) {
                gui.service_eventRemoveDocentSuccessful();
            }
        }
        );     
    }
    
}